#include <iostream>
#include <string>
#include <memory>
#include <ctime>
#include <unistd.h>
#include <unordered_map>


class Session
{
public:
    Session(const std::string name,const std::string password,const std::string status)
    :_name(name),
    _password(password),
    _status(status)
    {}

    std::string GetName()
    {
        return _name;
    }

    std::string GetPassword()
    {
        return _password;
    }
    ~Session() = default;
private:
    std::string _status;    //状态
    std::string _name;  //用户名
    std::string _password;   //密码
};


using session_ptr = std::shared_ptr<Session>;
class SessionManager
{
public:
    SessionManager()=default; 

    std::string AddSession(const std::string name,const std::string password,const std::string status)
    {
        session_ptr sp = std::make_shared<Session>(name,password,status);
        std::string id =std::to_string(time(nullptr));

        mp[id] = sp;

        return id;
    }

    session_ptr GetSession(std::string id)
    {
        auto pos = mp.find(id);
        if(pos == nullptr)
            return nullptr;
        
        return mp[id];
    }
    
    ~SessionManager() = default;

private:
    std::unordered_map<std::string,session_ptr> mp;
};